// pages/index3/index3.js
Page({

    /**
     * 组件的属性列表
     */
    properties: {},

    /**
     * 组件的初始数据
     */
    data: {
        termid:"",
        scorename:"",
        terms: [
            {
                name: "2022-2023 第二学期",
                id: 2
            },
            {
                name: "2023-2024 第一学期",
                id: 3
            },
        ],
        subs: [{
                name: "操作系统",
                id: 1
            },
            {
                name: "普通物理学B",
                id: 2
            },
            {
                name: "大学英语",
                id: 3
            },
            {
                name: "数据结构",
                id: 4
            }
        ],
        cursubName: "请选择学科",
        title: "学科",
        list:null,
        header: null
    },
    changes(e) {
        this.setData({
            termid: e.detail.selectId,
        })
        var that = this;
        wx.request({
            url: 'http://vz3q9q.natappfree.cc/getScoreByCname?classno=1&term='+this.data.termid+'&cname='+this.data.select,
            method: 'POST',
            data: {
                rnum: 2,
                username: 'test1'
            },
            header: {
                'content-type': 'application/x-www-form-urlencoded'
            },
            dataType: 'json',
            success(res) {
                console.log(res.data);
                that.setData({
                    list: res.data.data,
                    header: res.data.headers
                });
            }
        });
        console.log(e.detail.selectId);
        console.log(e.detail.select);
    },
    changes1(e) {
        this.setData({
            scorename: e.detail.select,
        })
        var that = this;
        wx.request({
            url: 'http://vz3q9q.natappfree.cc/getScoreByCname?classno=1&term='+this.data.termid+'&cname='+this.data.scorename,
            method: 'POST',
            data: {
                rnum: 2,
                username: 'test1'
            },
            header: {
                'content-type': 'application/x-www-form-urlencoded'
            },
            dataType: 'json',
            success(res) {
                console.log(res.data);
                that.setData({
                    list: res.data.data,
                    header: res.data.headers
                });
            }
        });
        console.log(e.detail.selectId);
        console.log(e.detail.select);
    },
})